
 VSP=V;
 bgrid_SP=bgrid_large;
QSP=eQ_temp_large;

bpSP=bp;

moments_inorder=[mean(NFA),avPvD,avPub,avSpr,std(NFA),a_Std_PvDebt,a_Std_PubDebt,a_Std_Spr]

 clear bpSIM VSIM bSIM V BGpSIM BGSIM S_index BGiSIM bgrid Q bp
 
 load simDE.mat
%load simDE170_exo.mat
 
[T,~]=size(VSIM);
VSPSIM=zeros(T,1);
N=1;


parfor i=1:T
    for j=1:N
   
    VSPSIM(i,j)=interp1(squeeze(bgrid(1,:)),squeeze(VSP(BGiSIM(i,j),:,S_index(i))),bSIM(i,j),'linear','extrap');
    end
end

Wf_Gains=((VSPSIM*(1-sigma)*(1-beta)+ones(T,1))./(VSIM*(1-sigma)*(1-beta)+ones(T,1))).^(1/(1-sigma))-ones(T,1);
mean(Wf_Gains)*100;